package com.define.ssh.action.monitoring;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.ParentPackage;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.define.ssh.action.admin.BaseAdminAction;
import com.define.ssh.model.MAlartDetail;
import com.define.ssh.model.MWarnDetail;
import com.define.ssh.model.TbLog;
import com.define.ssh.model.Terminal;
import com.define.ssh.model.UserInfo;
import com.define.ssh.service.MAlartDetailService;
import com.define.ssh.service.MWarnDetailService;
import com.define.ssh.service.TbLogService;
import com.define.ssh.util.SystemUtil;
import com.define.ssh.util.Pager.Order;


/**
 *  
 * 
 */
@ParentPackage("admin")
public class AlarmDataAction extends BaseAdminAction {

	/** 页面传递参数过来 */
	protected int pageSize;
	protected int pageNum;
	
	@Resource(name = "malartDetailServiceImpl")
	private MAlartDetailService  malartDetailService;

	/**
	 * 列表页
	 * 
	 * @return
	 * @throws Exception
	 */
	public String list() {

		
		
	try {
			
			HashMap<String, Object> searchMap = new HashMap<String, Object>();
			pager.setOrder(Order.desc);
			pager.setOrderBy("updatetime");
			pager.setSearchMap(searchMap);
			pager =malartDetailService.findPager(pager);
			
			List<MAlartDetail> list= (List<MAlartDetail>) pager.getResult();
			for (MAlartDetail malartDetail : list) {
				
				 DetachedCriteria dt2 = DetachedCriteria.forClass(Terminal.class);	
				 dt2.add(Restrictions.eq("netid",Long.valueOf(malartDetail.getNetid())));
				 List  terlist=malartDetailService.findByCriteria(dt2);
				 if(terlist!=null&&terlist.size()>0){
					 Terminal terminal=(Terminal)terlist.get(0);
					 malartDetail.setPname(terminal.getName());
					
				 }
			}
			
			} catch (Exception e) {
				e.printStackTrace();
			}

		return "alarmData";
	}

}
